<link href="/theme/Default/css/shop/shop.css" rel="stylesheet">

<div class="nav-container">
	<a href="#">Toàn bộ danh mục</a> » Gian hàng tham gia maytot.vn
</div>

<div class="container-shop">
	<ul class="shop">
		<!--
		//Model template
		<li class="shop-list">
			<ul>
				<li class="title-list">Thiết bị nâng hạ</li>
				<li><a href="/shopDetail/xe-nang-forklift-074600.html">﻿Xe nâng – forklift<span>(2)</span></a></li>
				<li><a>Xe nâng tay<span>(0)</span></a></li>
			</ul>
			<ul>
				<li class="title-list">Thiết bị nâng hạ</li>
				<li><a href="/shopDetail/xe-nang-forklift-074600.html">﻿Xe nâng – forklift<span>(2)</span></a></li>
				<li><a>Xe nâng tay<span>(0)</span></a></li>
			</ul>
		</li>
		<li class="shop-list">
			<ul>
				<li class="title-list">Thiết bị nâng hạ</li>
				<li><a href="/shopDetail/xe-nang-forklift-074600.html">﻿Xe nâng – forklift<span>(2)</span></a></li>
				<li><a>Xe nâng tay<span>(0)</span></a></li>
			</ul>
			<ul>
				<li class="title-list">Thiết bị nâng hạ</li>
				<li><a href="/shopDetail/xe-nang-forklift-074600.html">﻿Xe nâng – forklift<span>(2)</span></a></li>
				<li><a>Xe nâng tay<span>(0)</span></a></li>
			</ul>
		</li>
	-->
		<?php 

			$temp_root_category_id = 0;// Save id of root_categories
			$count = 0;// Save count of root_categories
			$isFlag = false;
			foreach ($data as $item)
			{
				if($item['h']['category_id'] == 0) continue;

				if(!$isFlag)// Begin to start shop-list
				{
					$isFlag = true;
		?>
				<li class="shop-list">
		<?php
				}
		?>
		<?php		

				if ($temp_root_category_id == 0)
				{
					$temp_root_category_id = $item['h']['root_category_id'];
		?>
					<ul>
						<li class="title-list">
							<?php echo $item['h']['root_category_name']?>
						</li>
		<?php					
				}

				if ($item['h']['root_category_id'] != $temp_root_category_id)// End child group of root_categories
				{
					$temp_root_category_id = $item['h']['root_category_id'];
					$count++;

					if($count % $num_col_div == 0)// Divide number column
					{
		?>
					</ul>
				</li>
				<li class="shop-list">
		<?php		
					}
					else
					{
		?>
					</ul>
		<?php
					}
	    ?>
					<ul>
		    			<li class="title-list">
							<?php echo $item['h']['root_category_name']?>
						</li>
		<?php
				}
		?>
						<li>
		<?php 
				if($item['h']['total'] == 0)
				{
		?>
							<a>
								<?php echo $item['h']['category_name']?>
								<span>(<?php echo $item['h']['total']?>)</span>
							</a>
		<?php
				}
				else
				{
		?>
							<a href="/shopDetail/<?php echo $item['h']['short_link'];?>">
								<?php echo $item['h']['category_name']?>
								<span>(<?php echo $item['h']['total']?>)</span>
							</a>
		<?php
				}
		?>
						</li>
		<?php 
			}
		?>
					</ul>
			</li>
		</ul>
	<div class="clear"></div>
</div>